package com.jawmask.android.stuartproair.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

import com.jawmask.android.stuartproair.R;
import com.jawmask.android.stuartproair.constants.UIUtils;

public class ServicesActivity extends BaseListActivity {

	private String[] targetServiceHttpUrlLinks;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.list_view_layout, true);
		setTitle(getString(R.string.services_title));

		targetServiceHttpUrlLinks = getResources().getStringArray(R.array.target_service_http_urlLinks);

		setListAdapter(new ListItemAdapter(getResources().getStringArray(R.array.services)));
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		String selectedServiceName = (String) getListAdapter().getItem(position);
		if (selectedServiceName.equals(getString(R.string.schedule_an_appointment))) {
			launchSchedulerScreen();
		} else {
			String targetServiceHttpLink = targetServiceHttpUrlLinks[position];
			UIUtils.getInstance().launchWebBrowserScreen(this, targetServiceHttpLink, selectedServiceName);
		}
	}
}